<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./lib/axios.js"></script>
</head>
<body>
    <h1>收货地址</h1>
    <button><a href="./page/xz.html">新增</a></button>
    <ul class="list"></ul>
    <script>
        axios.get('/a').then((res) => {
            console.log(res.data);
            fn(res.data)
        })
        let list=document.querySelector('.list');
        list.onclick = function(e) {
            let el=e.target;
            // 判断点击的是不是修改
            if(el.innerHTML==='修改'){
                let index=[...list.children].indexOf(el.parentNode);
                // 存储到本地
                localStorage.setItem('index',index);
                // 跳转页面
                location.href='./page/xg.html'
            }
        }
        // 渲染
        function fn(arr){
            list.innerHTML=arr.map(item=>`<li>${item.name} ${item.phone} ${item.dz} <span>修改</span> <span>删除</span><li>`)
        }
    </script>
</body>
</html>